


/**带参数访问服务器的action并且打印出返回结果*/
function handleItem(url) {
	layer.confirm('确认要进行该项操作吗？',function(){
		$.get(url, function(data){
			layer.alert(data, 9);
			location.replace(location.href);
			});
	});
}


/***
 * 把表格中被选中的条目值全部发送到服务器，并打印出返回结果
 */
function handleItems(url) {
	var nodes = $("tbody [type='checkbox']");
	var ids = "";
	var item = 0;
	nodes.each(function(i) {
		var isChecked = this.checked;
		if (isChecked) {
			item++;
			ids += nodes.eq(i).attr('value') + ","
		}
	});
	if (item == 0) {
		layer.msg("请先选择您要操作的条目",2,3);
		return;
	} else {
		layer.confirm("确定要对这 " + item + " 个条目进行该项操作吗？",function(){
			$.get(url+"&ids="+ ids, function(data){
				layer.alert(data, 9);
				location.replace(location.href);
				});
		});
	}
}





/****
 * 这个上移的方法有待改进，要脱离这个id的限制
 */
$(document).ready(function() {
	//上移

	$(".upbt").each(function() {
		$(this).click(function() {

			var $tr = $(this).parents("#sameGradeTab tr");
			if ($tr.index() != 1) {
				$tr.prev().before($tr);
			}

		});
	});

	//下移
	var trLength = $(".downbt").length;
	$(".downbt").each(function() {
		$(this).click(function() {
			var $tr = $(this).parents("#sameGradeTab tr");
			if ($tr.index() != trLength - 0) {
				$tr.next().after($tr);
			}
		});
	});

});


/***
 * 修改操作分值
 * @param url
 */

function updateScore(url){
	layer.prompt({title: '请新的分值'}, function(name){
	    var score=encodeURI(name);
	    $.get(url+'&score='+score, function(data){
	    	location.replace(location.href);
			layer.alert(data, 9);
		});
	});
}












/*****
 * ajax拒绝审核元素
 */

function refuseElement(url){
	layer.prompt({title: '请输入拒绝通过的理由！'}, function(name){
	    var reason=encodeURI(name);
	    $.get(url+'&reason='+reason, function(data){
	    	location.replace(location.href);
			layer.alert(data, 9);
		});
	});
}

function refuseElements(url){
	 var nodes = $("tbody [type='checkbox']");
		var ids = "";
		var item = 0;
		nodes.each(function(i) {
			var isChecked = this.checked;
			if (isChecked) {
				item++;
				ids += nodes.eq(i).attr('value') + ","
			}
		});
	if (item == 0) {
		layer.msg("请先选择您要拒绝的条目",2,3);
		return;
	}else {
		layer.prompt({title: '请输入拒绝通过的理由！'}, function(name){
	    var reason=encodeURI(name);
	   
		
			layer.confirm("确定要拒绝这 " + item + " 个条目吗？",function(){
				$.get(url+"&ids="+ ids+'&reason='+reason, function(data){
					layer.alert(data, 9);
					location.replace(location.href);
					});
			});
	});
	}
}


/*****
 * ajax冻结账户
 *  */

function frozenAccount(url){
	layer.prompt({title: '请输入冻结账户的理由！'}, function(name){
		var reason=encodeURI(name);
		$.get(url+'&reason='+reason, function(data){
			location.replace(location.href);
			layer.alert(data, 9);
		});
	});
}

function unfrozenAccount(url){
	$.get(url, function(data){
		layer.alert(data, 9);
		location.replace(location.href);
	});
}

